package com.dingreading.cloud.admin.util;

import com.dingreading.cloud.admin.entity.CourseTrain;
import com.dingreading.cloud.admin.entity.CourseTrainFile;
import com.dingreading.cloud.admin.entity.CourseTrainTypes;
import com.dingreading.cloud.common.util.KitUtil;
import com.dingreading.cloud.common.util.NepUtil;

public class CourseTrainUtil {
    public static CourseTrainTypes newMainCourseTrainTypes(
            String typeName, int levelEnd, Integer maxShowOrder, String headStaffUid, String headStaffName
    ) {
        CourseTrainTypes types = new CourseTrainTypes();
        types.setUid(KitUtil.getUuid());
        types.setTypeName(typeName);
        types.setLevelEnd(levelEnd);
        types.setLevelIndex(0);
        types.setShowOrder(0);
        types.setShowOrder(maxShowOrder);
        types.setParentId(0L);
        types.setEnabled(1);
        types.setAddStaffUid(headStaffUid);
        types.setAddStaffName(headStaffName);
        types.setLastStaffUid(headStaffUid);
        types.setLastStaffName(headStaffName);
        return types;

    }

    public static CourseTrainTypes newChildCourseTrainTypes(
            Long mainId, Long parentId, String typeName, Integer maxShowOrder,
            Integer levelEnd, Integer levelIndex, String headStaffUid, String headStaffName
    ) {
        CourseTrainTypes types = new CourseTrainTypes();

        types.setUid(KitUtil.getUuid());
        types.setTypeName(typeName);
        types.setLevelEnd(levelEnd);
        types.setLevelIndex(levelIndex);
        types.setMainId(mainId);
        types.setShowOrder(maxShowOrder);
        types.setParentId(parentId);
        types.setEnabled(1);
        types.setAddStaffUid(headStaffUid);
        types.setAddStaffName(headStaffName);
        types.setLastStaffUid(headStaffUid);
        types.setLastStaffName(headStaffName);

        return types;
    }

    public static CourseTrain newCourseTrainBean(
            String name, String intro, Integer maxOrderNum,
            String mainTypeUid, String typeUid, String nodes, String headStaffUid, String headStaffName
    ) {
        CourseTrain data = new CourseTrain();
        data.setUid(KitUtil.getUuid());
        data.setName(name);
        data.setIntro(intro);
        data.setOrderNum(maxOrderNum);

        data.setMainTypeUid(mainTypeUid);
        data.setTypeUid(typeUid);
        data.setEnabled(1);
        data.setTrainNodes(nodes);

        data.setAddStaffUid(headStaffUid);
        data.setAddStaffName(headStaffName);
        data.setLastStaffUid(headStaffUid);
        data.setLastStaffName(headStaffName);
        return data;
    }

    public static CourseTrainFile newTrainFile(
            String name, String url, String lessonUid, Integer fileType, Integer videoDuration, String headStaffUid, String headStaffName
    ) {
        CourseTrainFile courseTrainFile = new CourseTrainFile();
        courseTrainFile.setUid(KitUtil.getUuid());
        courseTrainFile.setName(name);
        courseTrainFile.setUrl(url);
        courseTrainFile.setTrainUid(lessonUid);
        courseTrainFile.setFileType(fileType);
        courseTrainFile.setEnabled(1);
        courseTrainFile.setDownloadNum(0);
        courseTrainFile.setVideoDuration(NepUtil.nullToZero(videoDuration));
        courseTrainFile.setAddStaffUid(headStaffUid);
        courseTrainFile.setAddStaffName(headStaffName);
        courseTrainFile.setLastStaffUid(headStaffUid);
        courseTrainFile.setLastStaffName(headStaffName);
        return courseTrainFile;
    }
}
